package weaver.interfaces.expense.action.gzc.th;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.util.ExpenseCompare;
import weaver.interfaces.util.ExpenseCompareUtil;
import weaver.interfaces.util.ExpenseInfoUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
/**
 * 
 * @ClassName: YSKFWZLY_TH_ExpenseAction
 * @Description: 院所库房物资领用单预算检查
 * @author xiyufei
 * @date 2017-3-20 上午11:19:21 
 *
 */
public class YSKFWZLY_TH_ExpenseAction  extends BaseBean{

 
	public void execute(String workflowid,String requestid) {
			writeLog("进入YSKFWZLY_TH_ExpenseAction-----------"+requestid);
			RecordSet rs = new RecordSet(); 
			rs.executeSql("select formid from workflow_base where id = " + workflowid);
			rs.next();
			String formid = rs.getString("formid");
			String formtable = "formtable_main_" + formid.replaceAll("-", "");
			ExpenseInfoUtil expenseInfoUtil = new ExpenseInfoUtil();
			String ccode = "";
			double amount = 0;
			String cexpenseitemcode = "";
			String citemcode = "";
			String iyear = "";
			String iskt ="0";
			//System.out.println("select  id,ks,cexpenseitemcode,citemcode,zje,zjly,sqrq,kth from "+formtable+" where requestid="+requestid);
			rs.execute("select a.id,b.ks,a.zcxm,a.je,b.zj,b.sqrq,b.kth2,b.sf from "+formtable+"_dt1 a , "+formtable+" b where a.mainid=b.id and  b.requestid="+requestid);
			while(rs.next()){  
				ccode =  expenseInfoUtil.getKsbm(Util.null2String(rs.getString("ks"))); 
				amount =  Util.getDoubleValue(rs.getString("je"),0); 
				cexpenseitemcode=  Util.null2String(rs.getString("zcxm"));  
				String kth =  Util.null2String(rs.getString("kth2"));  
				iyear =  Util.null2String(rs.getString("sqrq")).substring(0,4); 
				String sfkt = Util.null2String(rs.getString("sf")); 
				if("0".equals(sfkt)){// 课题号+项目支出
					iskt ="1";
				}
				boolean bl = expenseInfoUtil.releaseExpense(workflowid, ccode, cexpenseitemcode, citemcode, kth, amount, iyear,iskt);
			} 
	}

}
